<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet"
	href="../../../css/Semantic-UI-CSS-master/semantic.min.css" />
<link rel="stylesheet" href="../../../js/layui/css/layui.css" />
<script src="../../../js/layui/layui.js"></script>
<script src="../../../js/vue/axios.min.js"></script>
<script src="../../../js/vue/vue.js"></script>

<style>
.container {
	margin-top: 80px;
	margin-left: 90px;
}

input {
	margin: 10px;
}

.layui-btn {
	margin-left: 110px;
}
.layui-form-item{
	margin-top: 150px;
}
</style>
</head>
<body>

	<div id="app" class="layui-form">
		<div class="container">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">标签名称：</label>
				<div class="layui-input-inline">
					<input type="text" v-model="tag_name" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<button class="layui-btn" @click="add">提交</button>
				<button type="button" class="layui-btn layui-btn-primary" id="close">关闭</button>
			</div>

		</div>
	</div>
	<script>
	
	
	//添加
	new Vue({
		el:'#app',
		data:{
			//标签名
			tag_name:""
		},
		methods:{
			//新增
			add:function(){
				if(this.tag_name!=null && this.tag_name!='' && this.tag_name.indexOf(" ")==-1){
				axios.get('/ssb/tag/add?tag_name='+this.tag_name).then(res=>{
					console.log(res);
					if(res.data>0){
						succeed()
					}
				},err=>{
					console.log(err);
				});
			}else{
				alert("必填项不能为空（包括空格）");
			}
			}
		}
	});
	
	//操作成功
	function succeed() {
		layui.use(['form', 'jquery'], function() {
			layer.alert("添加成功！", function() {
				var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
				parent.layer.close(index);
				//关闭父级页面的表格
				parent.layui.table.reload('testReload');
			});
		});
	}
	
	//关闭
	layui.use(['form', 'jquery'], function() {
		var $=layui.jquery
	  $("#close").on('click',function(){
		layui.use(['form', 'jquery'], function() {
				var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
				parent.layer.close(index);
				//关闭父级页面的表格
				parent.layui.table.reload('testReload');
		});
	});
	
	});
	
	</script>
</body>
</html>
